.class public final Lorg/jboss/netty/util/internal/ExecutorUtil;
.super Ljava/lang/Object;
.source "ExecutorUtil.java"


# direct methods
.method private constructor <init>()V
    .locals 0

    .prologue
    .line 118
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 119
    return-void
.end method

.method public static isShutdown(Ljava/util/concurrent/Executor;)Z
    .locals 1
    .parameter "executor"

    .prologue
    .line 37
    instance-of v0, p0, Ljava/util/concurrent/ExecutorService;

    if-eqz v0, :cond_0

    .line 38
    check-cast p0, Ljava/util/concurrent/ExecutorService;

    .end local p0
    invoke-interface {p0}, Ljava/util/concurrent/ExecutorService;->isShutdown()Z

    move-result v0

    if-eqz v0, :cond_0

    .line 39
    const/4 v0, 0x1

    .line 42
    :goto_0
    return v0

    :cond_0
    const/4 v0, 0x0

    goto :goto_0
.end method

.method public static varargs terminate([Ljava/util/concurrent/Executor;)V
    .locals 14
    .parameter "executors"

    .prologue
    .line 50
    if-nez p0, :cond_0

    .line 51
    new-instance v11, Ljava/lang/NullPointerException;

    const-string v12, "executors"

    invoke-direct {v11, v12}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V

    throw v11

    .line 54
    :cond_0
    array-length v11, p0

    new-array v6, v11, [Ljava/util/concurrent/Executor;

    .line 55
    .local v6, executorsCopy:[Ljava/util/concurrent/Executor;
    const/4 v7, 0x0

    .local v7, i:I
    :goto_0
    array-length v11, p0

    if-ge v7, v11, :cond_2

    .line 56
    aget-object v11, p0, v7

    if-nez v11, :cond_1

    .line 57
    new-instance v11, Ljava/lang/NullPointerException;

    new-instance v12, Ljava/lang/StringBuilder;

    invoke-direct {v12}, Ljava/lang/StringBuilder;-><init>()V

    const-string v13, "executors["

    invoke-virtual {v12, v13}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v12

    invoke-virtual {v12, v7}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v12

    const-string v13, "]"

    invoke-virtual {v12, v13}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v12

    invoke-virtual {v12}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v12

    invoke-direct {v11, v12}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V

    throw v11

    .line 59
    :cond_1
    aget-object v11, p0, v7

    aput-object v11, v6, v7

    .line 55
    add-int/lit8 v7, v7, 0x1

    goto :goto_0

    .line 63
    :cond_2
    sget-object v11, Lorg/jboss/netty/util/internal/DeadLockProofWorker;->PARENT:Ljava/lang/ThreadLocal;

    invoke-virtual {v11}, Ljava/lang/ThreadLocal;->get()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Ljava/util/concurrent/Executor;

    .line 64
    .local v1, currentParent:Ljava/util/concurrent/Executor;
    if-eqz v1, :cond_4

    .line 65
    move-object v0, v6

    .local v0, arr$:[Ljava/util/concurrent/Executor;
    array-length v10, v0

    .local v10, len$:I
    const/4 v8, 0x0

    .local v8, i$:I
    :goto_1
    if-ge v8, v10, :cond_4

    aget-object v2, v0, v8

    .line 66
    .local v2, e:Ljava/util/concurrent/Executor;
    if-ne v2, v1, :cond_3

    .line 67
    new-instance v11, Ljava/lang/IllegalStateException;

    const-string v12, "An Executor cannot be shut down from the thread acquired from itself.  Please make sure you are not calling releaseExternalResources() from an I/O worker thread."

    invoke-direct {v11, v12}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v11

    .line 65
    :cond_3
    add-int/lit8 v8, v8, 0x1

    goto :goto_1

    .line 77
    .end local v0           #arr$:[Ljava/util/concurrent/Executor;
    .end local v2           #e:Ljava/util/concurrent/Executor;
    .end local v8           #i$:I
    .end local v10           #len$:I
    :cond_4
    const/4 v9, 0x0

    .line 78
    .local v9, interrupted:Z
    move-object v0, v6

    .restart local v0       #arr$:[Ljava/util/concurrent/Executor;
    array-length v10, v0

    .restart local v10       #len$:I
    const/4 v8, 0x0

    .restart local v8       #i$:I
    :goto_2
    if-ge v8, v10, :cond_7

    aget-object v2, v0, v8

    .line 79
    .restart local v2       #e:Ljava/util/concurrent/Executor;
    instance-of v11, v2, Ljava/util/concurrent/ExecutorService;

    if-nez v11, :cond_5

    .line 78
    :goto_3
    add-int/lit8 v8, v8, 0x1

    goto :goto_2

    :cond_5
    move-object v3, v2

    .line 83
    check-cast v3, Ljava/util/concurrent/ExecutorService;

    .line 86
    .local v3, es:Ljava/util/concurrent/ExecutorService;
    :cond_6
    :goto_4
    :try_start_0
    invoke-interface {v3}, Ljava/util/concurrent/ExecutorService;->shutdownNow()Ljava/util/List;
    :try_end_0
    .catch Ljava/lang/SecurityException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Ljava/lang/NullPointerException; {:try_start_0 .. :try_end_0} :catch_4

    .line 103
    :goto_5
    const-wide/16 v11, 0x64

    :try_start_1
    sget-object v13, Ljava/util/concurrent/TimeUnit;->MILLISECONDS:Ljava/util/concurrent/TimeUnit;

    invoke-interface {v3, v11, v12, v13}, Ljava/util/concurrent/ExecutorService;->awaitTermination(JLjava/util/concurrent/TimeUnit;)Z
    :try_end_1
    .catch Ljava/lang/InterruptedException; {:try_start_1 .. :try_end_1} :catch_2

    move-result v11

    if-eqz v11, :cond_6

    goto :goto_3

    .line 87
    :catch_0
    move-exception v4

    .line 90
    .local v4, ex:Ljava/lang/SecurityException;
    :try_start_2
    invoke-interface {v3}, Ljava/util/concurrent/ExecutorService;->shutdown()V
    :try_end_2
    .catch Ljava/lang/SecurityException; {:try_start_2 .. :try_end_2} :catch_1
    .catch Ljava/lang/NullPointerException; {:try_start_2 .. :try_end_2} :catch_3

    goto :goto_5

    .line 91
    :catch_1
    move-exception v5

    .line 94
    .local v5, ex2:Ljava/lang/SecurityException;
    goto :goto_3

    .line 106
    .end local v4           #ex:Ljava/lang/SecurityException;
    .end local v5           #ex2:Ljava/lang/SecurityException;
    :catch_2
    move-exception v4

    .line 107
    .local v4, ex:Ljava/lang/InterruptedException;
    const/4 v9, 0x1

    .line 108
    goto :goto_4

    .line 112
    .end local v2           #e:Ljava/util/concurrent/Executor;
    .end local v3           #es:Ljava/util/concurrent/ExecutorService;
    .end local v4           #ex:Ljava/lang/InterruptedException;
    :cond_7
    if-eqz v9, :cond_8

    .line 113
    invoke-static {}, Ljava/lang/Thread;->currentThread()Ljava/lang/Thread;

    move-result-object v11

    invoke-virtual {v11}, Ljava/lang/Thread;->interrupt()V

    .line 115
    :cond_8
    return-void

    .line 95
    .restart local v2       #e:Ljava/util/concurrent/Executor;
    .restart local v3       #es:Ljava/util/concurrent/ExecutorService;
    .local v4, ex:Ljava/lang/SecurityException;
    :catch_3
    move-exception v11

    goto :goto_5

    .line 98
    .end local v4           #ex:Ljava/lang/SecurityException;
    :catch_4
    move-exception v11

    goto :goto_5
.end method
